import {calc} from 'a-calc/es';

export default {
    data() {
        return {
            clzxJqsSubtotal: '',
            clzxQgSubtotal: '',
            form: {
                clzxJqsCount: '',
                clzxJqsChargingStandard: '',
                clzxJqsIsUp: '',
                clzxJqsSubtotal: 0,

                clzxQgCount: '',
                clzxQgChargingStandard: '',
                clzxQgIsUp: '',
                clzxQgSubtotal: 0,
            }
        }
    },
    watch: {
        // 车辆整修费-卸半轴，解气刹 - 数量
        'form.clzxJqsCount'(val) {
            if (val) {
                this.form.clzxJqsChargingStandard = 300
                !this.form.clzxJqsIsUp && (this.form.clzxJqsIsUp = '否')
            }
            this.getCheLiangZhengXiuFei()
        },
        // 车辆整修费-卸半轴，解气刹 - 收费标准
        'form.clzxJqsChargingStandard'() {
            this.getCheLiangZhengXiuFei()
        },
        // 车辆整修费-卸半轴，解气刹 - 上浮
        'form.clzxJqsIsUp'() {
            this.getCheLiangZhengXiuFei()
        },

        // 车辆整修费 气割，焊 - 数量
        'form.clzxQgCount'(val) {
            if (val) {
                this.form.clzxQgChargingStandard = 200
                !this.form.clzxQgIsUp && (this.form.clzxQgIsUp = '否')
            }
            this.getCheLiangZhengXiuFei2()
        },
        // 车辆整修费 气割，焊 - 上浮
        'form.clzxQgIsUp'() {
            this.getCheLiangZhengXiuFei2()
        },
        // 车辆整修费 气割，焊 - 收费标准
        'form.clzxQgChargingStandard'() {
            this.getCheLiangZhengXiuFei2()
        },
    },
    methods: {
        getCheLiangZhengXiuFei() {
            if (this.form.clzxJqsCount) {
                this.clzxJqsSubtotal = calc(`
				${this.form.clzxJqsChargingStandard || 0}
				* ${this.form.clzxJqsCount || 0}
				* (${this.form.clzxJqsIsUp === '是' ? 1.2 : 1})
			`)
            } else {
                this.form.clzxJqsIsUp = ''
                this.clzxJqsSubtotal = ''
                this.form.clzxJqsChargingStandard = ''
            }
        },
        getCheLiangZhengXiuFei2() {
            if (this.form.clzxQgCount) {
                this.clzxQgSubtotal = calc(`
				${this.form.clzxQgChargingStandard || 0}
				* ${this.form.clzxQgCount || 0}
				* (${this.form.clzxQgIsUp === '是' ? 1.2 : 1})
			`)
            } else {
                this.form.clzxQgIsUp = ''
                this.clzxQgSubtotal = ''
                this.form.clzxQgChargingStandard = ''
            }
        },
    },
}
